fix: stabilize local dev auth startup#3252
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review 1 blocking correctness issue found. This PR modifies runtime behavior in desktop auth startup and mobile keyboard/scroll handling. Unresolved review comments identify potential bugs in the scroll behavior changes that warrant human review before merging. You can customize Macroscope's approvability policy. Learn more. |
| const effect = Effect.gen(function* () { | ||
| const clientRequest = HttpClientRequest.fromWeb(new Request(targetUrl, init)); | ||
| const clientResponse = yield* httpClient.execute(clientRequest); | ||
| return withContentSecurityPolicy( | ||
| new Response( | ||
| request.method === "HEAD" ? null : Stream.toReadableStream(clientResponse.stream), | ||
| { | ||
| status: clientResponse.status, | ||
| headers: clientResponse.headers, | ||
| }, | ||
| ), | ||
| contentSecurityPolicy, | ||
| ); | ||
| }); |
There was a problem hiding this comment.
why was this made? i ran into clerk bot protection when the fetch was made using undici earlier
There was a problem hiding this comment.
This was an attempt to try keep the custom scheme for all app requests. However to avoid alot of the changes we could simply revert back to http://127.0.0.1 when clerk config is not present.
I'll push a fix
There was a problem hiding this comment.
It should be better now
Gate Clerk-dependent renderer and desktop bridge setup when local config is absent, register the desktop schemes independently, proxy custom-scheme requests through the app protocol, and load the diff worker via the portable package worker entry. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Route configured loopback HTTP requests through the Vite origin so browser-session cookies are scoped to the page origin, while preserving direct WebSocket targets. Dedupe same-token pairing submits and tolerate stale one-time-token retries when a session is already authenticated. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Stream desktop protocol proxy responses instead of buffering complete bodies, and wait for browser sessions to become observable after manual pairing exchanges. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 59f460b. Configure here.
| lastScrolledAnchorMessageIdRef.current = null; | ||
| freeze.set(false); | ||
| }, [freeze, selectedThreadKey]); | ||
| }, [selectedThreadKey]); |
There was a problem hiding this comment.
Composer inset stale after changes
Low Severity
Replacing the keyboard inset hooks with composerOverlayHeight state means contentBottomInset can stay at an old measured value when estimatedOverlayHeight drops (for example after switching threads or when the working indicator clears) until onComposerLayout runs again, leaving excess bottom padding on the thread feed.
Reviewed by Cursor Bugbot for commit 59f460b. Configure here.
There was a problem hiding this comment.
🟡 Medium
After sending a message from the focused composer, listRef.current?.scrollToEnd() runs immediately in the requestAnimationFrame callback, but at that point the keyboard is still dismissing and the KeyboardAvoidingLegendList has not finished adjusting its content insets. The scroll target is computed against the pre-keyboard-dismiss layout, so the newest message ends up scrolled underneath the closing keyboard instead of being fully visible. The previous useKeyboardScrollToEnd helper coordinated the scroll with the keyboard animation freeze so the list settled after the insets updated; removing it means freshly sent messages are not brought fully into view until the user manually scrolls.
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/mobile/src/features/threads/ThreadDetailScreen.tsx around line 289:
After sending a message from the focused composer, `listRef.current?.scrollToEnd()` runs immediately in the `requestAnimationFrame` callback, but at that point the keyboard is still dismissing and the `KeyboardAvoidingLegendList` has not finished adjusting its content insets. The scroll target is computed against the pre-keyboard-dismiss layout, so the newest message ends up scrolled underneath the closing keyboard instead of being fully visible. The previous `useKeyboardScrollToEnd` helper coordinated the scroll with the keyboard animation freeze so the list settled after the insets updated; removing it means freshly sent messages are not brought fully into view until the user manually scrolls.
|
This has been fixed in main, closing the PR |


What Changed
Why
Local development could fail when Clerk config was missing or when running the web dev flow through
vp run dev. Clerk was being loaded too eagerly, desktop scheme registration depended on Clerk bridge setup, diff worker imports could fail under Vite, and pairing-token exchange could consume a one-time token before the browser session was observable on the correct origin.This keeps local startup resilient without Clerk config, avoids CORS/cookie-origin issues by using the web/Vite origin for browser HTTP requests, and preserves direct loopback WebSockets where required.
UI Changes
Checklist
Note
Medium Risk
Desktop auth and renderer URL selection change in development, but production paths with a Clerk key stay on the custom protocol and bridge; mobile list scrolling behavior changes with the keyboard refactor.
Overview
Makes local desktop dev work without Clerk by gating every Clerk touchpoint on whether a valid build-time publishable key resolves to a Frontend API hostname.
Desktop: New
DesktopClerkConfigcentralizes hostname parsing andisDesktopClerkBridgeEnabled(). The Clerk SDK bridge, preloadexposeClerkBridge, and custom-scheme protocol registration are skipped when disabled; in that dev mode the main window loads the Vite dev server URL instead oft3code-dev://.makeDesktopClerkLayercan omit bridge acquire/release while still providing single-instance / second-window behavior.Mobile: Thread chat drops
KeyboardAwareLegendList/ shared-value keyboard inset hooks in favor ofKeyboardAvoidingLegendList, measured composer overlay height, and directscrollToEndafter send.Web: Adds a thin
TimelineLegendListtype wrapper so the timeline can passcontentInsetEndAdjustmentwithout fighting LegendList typings.Reviewed by Cursor Bugbot for commit 59f460b. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix local dev auth startup by conditionally initializing the Clerk bridge
isDesktopClerkBridgeEnabled() === false).t3code-devprotocol.ThreadDetailScreenandThreadFeedon mobile to useKeyboardAvoidingLegendListwith manual composer layout tracking, removing Legend keyboard helpers.Macroscope summarized 59f460b.